﻿using System;
using System.ComponentModel;
using System.Drawing;

namespace MaterialWinforms.Controls
{
    public partial class MaterialDropDownDatePicker : DropDownControl, IMaterialControl
    {
        [Browsable(false)]
        public int Depth { get; set; }

        [Browsable(false)]
        public MaterialWinformsManager SkinManager { get { return MaterialWinformsManager.Instance; } }

        [Browsable(false)]
        public MouseState MouseState { get; set; }

        public Color BackColor { get { return Parent == null ? SkinManager.GetApplicationBackgroundColor() : Parent.BackColor; } set { } }

        private MaterialDatePicker objDateControl;
        private DateTime _Date;
        public DateTime Date
        {
            get { return _Date; }
            set
            {
                _Date = value;
                Text = _Date.ToLongDateString();
            }
        }
        public MaterialDropDownDatePicker()
        {
            InitializeComponent();
            this.FontChanged += MaterialDropDownDatePicker_FontChanged;
            this.Date = DateTime.Now;
        }

        private void MaterialDropDownDatePicker_FontChanged(object sender, EventArgs e)
        {
            objDateControl = new MaterialDatePicker();
            Date = DateTime.Now;
            objDateControl.Date = _Date;
            objDateControl.onDateChanged += objDateControl_onDateChanged;
            InitializeDropDown(objDateControl, this.Font);
            this.FontChanged -= MaterialDropDownDatePicker_FontChanged;
        }

        void objDateControl_onDateChanged(DateTime newDateTime)
        {
            _Date = newDateTime;
            Text = newDateTime.ToLongDateString();
        }

        private void InitializeComponent()
        {
            this.SuspendLayout();
            // 
            // MaterialDropDownDatePicker
            // 
            this.AnchorSize = new Size(150, 21);
            this.AutoScaleDimensions = new SizeF(6F, 12F);
            this.Name = "MaterialDropDownDatePicker";
            this.ResumeLayout(false);
        }
    }
}
